package net.sample.gismeteo.svc;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * Receives system boot broadcast message and starts service on BOOT.
 * @author Vladimir Kozlov
 * @version $Id: $
 */
public class GisMeteoServiceBootStart extends BroadcastReceiver {

	private static final String TAG = "WeatherRetrievalServiceStarter";

	@Override
	public void onReceive(Context context, Intent intent) {
		if( "android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
			ComponentName comp = new ComponentName(context.getPackageName(), 
					WeatherRetrievalService.class.getName());
			ComponentName service = context.startService(new Intent().setComponent(comp));
			if (null == service){
			    Log.e(TAG, "Could not start service " + comp.toString());
			}
		} else {
				Log.e(TAG, "Received unexpected intent " + intent.toString());
		}
	}

}
